//
//  TFURLSessionManagerTaskDelegate.h
//  AFN_Test
//
//  Created by Guo Rui on 2017/9/18.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSString * const TFNetworkingTaskDidResumeNotifcation;
extern NSString * const TFNetworkingTaskDidSuspendNotifcation;
extern NSString * const TFNetworkingTaskDidCompletionNotification;


extern NSString * const TFNetworkingTaskDidCompleteResponseSerializerKey;
extern NSString * const TFNetworkingTaskDidCompleteSerializedResponseKey;
extern NSString * const TFNetworkingTaskDidCompleteResponseDataKey;
extern NSString * const TFNetworkingTaskDidCompleteErrorKey;

extern NSString * const TFURLSessionTaskDidFailToMoveFileNotifcation;

typedef NSURLSessionResponseDisposition (^TFURLSessionDataTaskDidReciveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response);
typedef void (^TFURLSessionDataTaskDidReciveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data);
typedef void (^TFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error);

typedef void (^TFURLSessionTaskProgressBlock)(NSProgress *progress);
typedef void (^TFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error);

typedef NSURL * (^TFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location);
typedef void (^TFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOff,int64_t expectedTotalBytes);

typedef void(^TFURLSessionUploadTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionUploadTask *uploadTask, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSent);
@class TFURLSessionManager;

@interface TFURLSessionManagerTaskDelegate : NSObject<NSURLSessionDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
- (instancetype)initWithTask:(NSURLSessionTask *)task;

@property (weak, nonatomic) TFURLSessionManager *manager;
@property (strong, nonatomic) NSMutableData *mutableData;
@property (strong, nonatomic) NSProgress *uploadProgress;
@property (strong, nonatomic) NSProgress *downloadProgress;

@property (nonatomic, copy) NSURL *downloadFileURL;

@property (copy, nonatomic) TFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
@property (copy, nonatomic) TFURLSessionTaskProgressBlock uploadProgressBlock;
@property (copy, nonatomic) TFURLSessionTaskProgressBlock downloadProgressBlock;
@property (copy, nonatomic) TFURLSessionTaskCompletionHandler completionHandler;
@end
